﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

namespace SportingGoodsExhibitionSystem
{
    /// <summary>
    /// detailInfo.xaml 的交互逻辑
    /// </summary>
    public partial class detailInfo : Window
    {
        public detailInfo()
        {
            InitializeComponent();
        }
        int stuNum;

        string strCon = Properties.Resources.strCON;

        public detailInfo(int stuNum)
        {
            InitializeComponent();
        
            this.stuNum = stuNum;
            
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            labelNum.Content = stuNum;
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from studentInfo where studentNumber=@num", con);
            cmd.Parameters.Add("@num", SqlDbType.Int, 10).Value = stuNum;
            SqlDataAdapter read = new SqlDataAdapter(cmd);
            //DataTable dt = new DataTable();
            DataSet dataset = new DataSet();
            read.Fill(dataset);
            DataTable table = dataset.Tables[0];
            DataRowCollection rows = table.Rows;
            DataRow row = rows[0];
            
            labelName.Content = row["studentName"].ToString();
            labelCollege.Content = row["studyCollege"].ToString();

            cmd = new SqlCommand("select * from applyBack where stunum=@num", con);
            cmd.Parameters.Add("@num", SqlDbType.Int, 10).Value = stuNum;
            SqlDataAdapter read1 = new SqlDataAdapter(cmd);
            //DataTable dt = new DataTable();
            DataSet dataset1 = new DataSet();
            read1.Fill(dataset1);
            DataTable table1 = dataset1.Tables[0];
            DataRowCollection rows1 = table1.Rows;
            DataRow row1 = rows1[0];

            labelTele.Content = row1["telephone"].ToString();
            labelAgr.Content = row1["agcypeo"].ToString();
            labelAgrRela.Content = row1["agcyrela"].ToString();
            labelAgrTele.Content = row1["agcytele"].ToString();

            con.Close();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            AdminStuHeaTable stuHeaTable = new AdminStuHeaTable(stuNum);
            stuHeaTable.Show();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            AdminStuBackInfo adminStuBackInfo = new AdminStuBackInfo(stuNum);
            adminStuBackInfo.Show();
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            AdminStuTranInfo adminStuTranInfo = new AdminStuTranInfo(stuNum);
            adminStuTranInfo.Show();
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            AdminPeoInfo adminPeoInfo = new AdminPeoInfo(stuNum);
            adminPeoInfo.Show();
        }
    }
}
